package com.wannengbang.cloudleader.homepage.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wannengbang.cloudleader.R;
import com.wannengbang.cloudleader.bean.ItemListDTO;
import com.wannengbang.cloudleader.bean.QueueRewardListBean;
import com.wannengbang.cloudleader.utils.DateTimeUtil;
import com.wannengbang.cloudleader.utils.NumberFormatUtils;

import java.util.Date;
import java.util.List;

/**
 * Author: HWC
 * Description: 合伙人列表
 */
public class NoticeAdapter extends BaseQuickAdapter<ItemListDTO.DataBean.itemList, BaseViewHolder> {

    public NoticeAdapter(List<ItemListDTO.DataBean.itemList> listsBeans) {
        super(R.layout.item_red_envelope_latest_list, listsBeans);
    }

    private int type;

    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, ItemListDTO.DataBean.itemList item) {

        String create_time = DateTimeUtil.format8_brief(new Date(Long.parseLong(item.getCreate_time() + "") * 1000));
        String money = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(item.getMoney() + "") / 100);
        helper.setText(R.id.tv_title, item.getAgent_name()+"  "+create_time+"  获取红包");
        helper.setText(R.id.tv_name, money);


    }

    @Override
    public ItemListDTO.DataBean.itemList getItem(int position) {
        int newPosition = position % getData().size();
        return getData().get(newPosition);
    }

    @Override
    public int getItemViewType(int position) {
        //刚开始进入包含该类的activity时,count为0。就会出现0%0的情况，这会抛出异常，所以我们要在下面做一下判断
        int count = getHeaderLayoutCount() + getData().size();
        if (count <= 0) {
            count = 1;
        }
        int newPosition = position % count;
        return super.getItemViewType(newPosition);
    }

    @Override
    public int getItemCount() {
        return Integer.MAX_VALUE;
    }
}
